import { Module } from '@nestjs/common';
import UserModule from './modules/User/user.module';
import { APP_GUARD, APP_INTERCEPTOR, APP_PIPE } from '@nestjs/core';
import { JwtAuthGuard } from './modules/guards/jwtGuard';
import DatabaseModule from './modules/database.module';
import { AppPipe } from './modules/core/providers/app.pipe';
import { ShopModule } from './modules/shop/shop.module';
import { MediaModule } from './modules/media/media.module';
import { LoggingInterceptor } from './modules/core/providers/app.interceptor';
import { PayModule } from './modules/pay/pay.module';

@Module({
  imports: [
    DatabaseModule.forRoot(),
    UserModule,
    ShopModule,
    MediaModule,
    PayModule,
  ],
  providers: [
    {
      provide: APP_GUARD,
      useClass: JwtAuthGuard,
    },
    {
      provide: APP_INTERCEPTOR,
      useClass: LoggingInterceptor,
    },
    {
      provide: APP_PIPE,
      useValue: new AppPipe({
        transform: true,
        forbidUnknownValues: true,
        validationError: { target: false },
      }),
    },
  ],
})
export class AppModule {}
